<?php

class Model_Cfg_LgnAcntProfile extends Jwawa_BaseModel
{
    protected static $validators = array(
        'id' => array(
            'rules' => array('Int' => null),
            'require' => true,
            'for' => array('update')
        ),
        'login_account_id' => array(
            'rules' => array('Int' => null),
            'require' => true
        ),
        'attr_key' => array(
            'rules' => array(
                'StringLength' => array('min' => 1,'max' => 50)
            ),
            'require' => true
        ),
        'attr_value' => array(
            'rules' => array(
                'StringLength' => array('min' => 1,'max' => 100)
            ),
            'require' => true
        ),
    );

    public static function  findProfileValuesByKey($loginAccountId, $attrKey){
        $sql = "SELECT clap.id,
                  clap.login_account_id,
                  clap.attr_key,
                  clap.attr_value
                FROM cfg_lgn_acnt_profiles clap
                WHERE clap.login_account_id = :login_account_id
                  AND clap.attr_key = :attr_key";

        $stmt = self::createDefaultStmt(self::getDb(), $sql);
        $stmt->bindValue('login_account_id', $loginAccountId);
        $stmt->bindValue('attr_key', $attrKey);
        $stmt->execute();
        $rst = $stmt->fetchAllObj();

        return $rst;
    }
}
